import data
import re
import matplotlib.pyplot as plt

SamplingF = 2*10**9  # sampling frequency
Signal = []  # list to save Class_signal
IndependantV = []  # independent variable. !diff in diff test!
DependatV = []  # dependent variables. calculated
# select file and read csv
S, Pathname = data.readcsv()
for i in Pathname:
    Sdata, P = data.readcsv(i)
    Signal.append(data.signal(Sdata, SamplingF))
    # regular expression to extract needed num in path
    numlist = re.findall(r"\d+\.?\d*", i)
    # test 1 corresponding to energy
    # !!! need modification for different test !!!
    IndependantV.append(int(numlist[2]))
    S_mean, S_sigma, S_skew, S_kurtosis = Signal[-1].parameters()
    DependatV.append(S_kurtosis[2])   # index here means the ith signal in csv

print(Pathname)
print(IndependantV)
print(DependatV)

ax1 = plt.subplot(311)
plt.plot(IndependantV, DependatV, 'ro')
plt.setp(ax1.get_xticklabels(), fontsize=16, family='Times New Roman')
plt.show()
# Signal[0].mapsignal()
# plt.show()
# plt.close()


# S_mean, S_sigma, S_skew, S_kurtosis = Signal[0].parameters()
# print(S_mean)
# print(S_kurtosis)
# print(S_sigma)
# print(S_skew)

